#include <iostream>
using namespace std;

struct Document
{
	int score;
	Document(int score)
	{
		this->score = score;
	}
};


class Approve 
{
protected:
	Approve* next;
public:
	virtual ~Approve() {}
	virtual void perform(Document* doc)=0;
	void setNext(Approve* next) 
	{
		this->next = next;
	}
	Approve* getNext() 
	{
		return this->next;
	}
};

class ManagerApprove: public Approve 
{
public:
	void perform(Document* doc) {
		cout << "The manager approve the document: ";
		if(doc->score<50) 
		{
			cout << "No pass" << endl;
			return;
		} else 
		{
			cout << "Pass" << endl;
			if(next) next->perform(doc);
		}
	}
};

class DirectorApprove: public Approve 
{
public:
	void perform(Document* doc) {
		cout << "The director approve the document: ";
		if(doc->score<80) {
			cout << "No pass" << endl;
			return;
		} else 
		{
			cout << "Pass" << endl;
			if(next) next->perform(doc);
		}
	}
};

int main() {
	Approve* approve = new ManagerApprove();
	approve->setNext(new DirectorApprove());

	cout << ">>> approve a document with 100 score ..." << endl;
	Document* doc0 = new Document(100);
	approve->perform(doc0);

	cout << ">>> approve a document with 70 score ..." << endl;
	Document* doc1 = new Document(70);
	approve->perform(doc1);
	
	cout << ">>> approve a document with 20 score ..." << endl;
	Document* doc2 = new Document(20);
	approve->perform(doc2);
	return 0;
}
